<template>
	
 	<div class="layui-layout layui-layout-admin" >
 	  <div class="adminnav1">	
        <Pagetop></Pagetop>
      </div>
      <div class="adminnav2">	
       	<Secondnav urlname="shopmall"></Secondnav>
      </div>
      
      <!-- 主体内容 -->
      <div class="layui-body kedou-admin" id="LAY_app_body app">
	    <div class="layadmin-tabsbody-item layui-show">
	    	<div class="pagelist">
	    		<div class="layui-card-body">
		      		<fieldset class="layui-elem-field layui-field-title">
					  <legend>商城订单</legend>
					</fieldset>
		      	</div>
	    		<div class="pagetop">
	    			<Search :seadate="searchArr"></Search>			    	
		        </div>
		        <div class="layui-card-body">
		        	<!--<div class="buttop">
					    <button type="button" class="layui-btn  layui-btn-normal" @click="addData">添加商城订单</button>
					</div>-->
			        <Tables :fdate="pdate" :result="res" height="430" :totalCount="totalRows" :pageNumber="curindex" :fbtn="btn"></Tables>      			     
		        </div>		      
	        </div>
	    </div>
	  </div>  
	     
	</div>
</template>
<script>	
	import Pagetop from '../../common/pagetop.vue'
	import Secondnav from '../../common/secondnav.vue'
	import Tables from '../../common/tables.vue'
	import Search from '../../common/search.vue'
	export default {
	  name: 'shoporderlist',
	  components: {Pagetop,Secondnav,Tables,Search},	  
	  data () {
	    return {
	        pdate:[], //表头  	
	    	res:"", //内容
	    	totalRows:"",//总数量
	    	curindex:1, //页数
	    	btn:[],//按钮
	    	searchArr:[],//搜索
	    	isShow:false, 
	    	seapram:'',
	    	condition:'all'
	    }
	  },
	  mounted(){ 	
	  	this.getdate();
     	this.getsearch();        
	  },
	  methods: {	 	  
		getdate:function(){     	
    	var _this=this;    	    	
    	//var url="/order/listJson"
    	//var url="/order/bapi/v1.9/order?page="+page+condition+'&sort=createAt,DESC';
    	var url="/order/bapi/v1.9/order"
    	if(_this.seapram){
    		var dates={
	    		//pageSize:pageSize,
	    		page:this.curindex,
	    		condition:this.condition,
	    		sort:'createAt,DESC',
	    	}
    		var res=_this.seapram;
    		for(var i=0;i<res.length;i++){
    			if(res[i].val){
    				dates[res[i].key]=res[i].val;
    			}
    		}
    		
    	}else{
	    	var dates={
	    		pageSize:pageSize,
	    	}
       }    		    	
    	ajaxRequest(url,'GET','json',dates,function(ret,err){
    		console.log(url+"//"+JSON.stringify(ret))
	  		var arr=[];  		
		  	arr[0]=[ 
		       {field: 'id', title: 'ID',width:'120',}	
		      ,{field: 'serialNo', title: '订单号',width:'170'}		     
		      ,{field: 'accountName', title: '用户账号',width:'120'}
		      ,{field: 'dealerName', title: '商家账号',width:'120'}
		      ,{field: 'shopName', title: '门店名',width:'120'}
		      ,{field: 'status', title: '状态',width:'130',templet:function(d){		      
		      	if(d.status=='UNPAID'){
		      		return '等待付款'	       		
		       	}else if(d.status=='PAID'){
		       		return '已付款'
		       	}else if(d.status=='GOODS_RECEIVED'){
		       		return '等待收货'
		       	}else if(d.status=='COMPLETED'){
		       		return '已完成'	
		       	}else if(d.status=='WITHDRAW'){
		       		return '取消订单申请'	
		       	}else if(d.status=='CANCEL'){
		       		return '已取消'	
		       	}else if(d.status=='APPLY_REFUND'){
		       		return '申请退款'	
		       	}else if(d.status=='REFUND'){
		       		return '已退款'	
		       	}
		       }}
		      ,{field: 'payAmount', title: '付款金额(元)',width:'120',templet:function(d){return d.payAmount/100}}
		      ,{field: 'totalAmount', title: '总金额(元)',width:'120',templet:function(d){return d.totalAmount/100}}
		      ,{field: 'postage', title: '邮费（元）',width:'120',templet:function(d){return d.postage/100}}		     
		      ,{field: 'memberNote', title: '买家备注',width:'120'}
		      ,{field: 'sellerNote', title: '卖家备注',width:'120'}
		      ,{field: 'right',title: '操作', width:'120', fixed:'right',templet:function(d){ 
		         var str='<a class="layui-btn layui-btn-xs layui-btn-normal" lay-event="detail">详情</a>';
		         var str1='<a class="layui-btn layui-btn-xs layui-btn-normal" lay-event="edit">货品</a>';
		         return str;
		      }}
		    ];		   
		  	_this.pdate=arr;		  	
		  	_this.res=ret.data.list;
		  	_this.totalRows=ret.data.totalRows;
		  	_this.curindex=ret.data.pageNumber;		 
		  	
	    })	
    },     
    getsearch:function(){
    	var arr=[
    		{field: 'status', title: '订单状态',type: 'select',option:[{val:'-1',name:'全部'},{val:'1',name:'待付款'},{val:'2',name:'待发货'},{val:'3',name:'待收货'},{val:'4',name:'已完成'},{val:'5',name:'取消订单申请'},{val:'6',name:'已取消'},{val:'7',name:'申请退款'},{val:'8',name:'已退款'}]} 
    		,{field: 'payStatus', title: '支付状态',type: 'select',option:[{val:'-1',name:'全部'},{val:'1',name:'未付款'},{val:'2',name:'已付款'},{val:'3',name:'已退款'}]}
    		,{field: 'createAtBegin', title: '开始时间',type: 'input',cid:'statbegAt'}
    		,{field: 'createAtEnd', title: '结束时间',type: 'input',cid:'lastbegAt'}
    	];
    	this.searchArr=arr;
   		setTimeout(function(){
   			var _this=this;
		  	layui.use('laydate', function(){	  			  
			  	var laydate = layui.laydate;				  	
		  		laydate.render({
			    	elem: '#statbegAt',
					  type: 'date',
					  btns: ['clear','now','confirm'],
					  done: function(value, date){						  	
					  					    
					  }
			  	});				  	
			});
			
			layui.use('laydate', function(){	  			  
			  	var laydate = layui.laydate;				  	
		  		laydate.render({
			    	elem: '#lastbegAt',
					  type: 'date',
					  btns: ['clear','now','confirm'],
					  done: function(value, date){						  	
					    					    
					  }
			  	});				  	
			});
   		},1000)
    },
    page:function(index,obj){
    	//alert(JSON,stringify(obj))
    	this.curindex=index;
    	this.getdate();
    	
    }, 
    sousuo:function(pram){
    	//alert(JSON.stringify(pram))
    	this.seapram=pram;
    	this.res='';
    	this.totalRows='';
    	this.curindex=1;
    	this.getdate();
    },
    addData:function(){
//		var _this = this;
//		layer.open({
//	        type: 2
//	        ,title: '创建信息'		        
//	        ,content:baseurl+'shopmalladd'
//	        ,area: _this.screens() < 2 ? ['90%', '80%'] : ['650px', '650px']
//      });	       
	},	
	editInfo:function(data){
		var _this = this;
		var id=data.id;
		layer.open({
            type: 2
            ,title: '验货信息'
            ,shadeClose: false//点击遮罩关闭
            ,content:baseurl+'shopgoods'
            ,area: ['90%', '80%']       
            ,success : function(layero, index){
		        var iframeWin = window[layero.find('iframe')[0]['name']];
		        iframeWin.getdates(id);
	        },	      
        });      
	},
	detailInfo:function(data){
		var _this = this;
		var id=data.id;		
	  	layer.open({
	      type: 2
	      ,title: '编辑资讯'
	      ,content:baseurl+'/shoporderxq'
	      ,area: ['90%', '80%']
	      ,success : function(layero, index){
	        var iframeWin = window[layero.find('iframe')[0]['name']];
	        iframeWin.getdates(id);
	      },
	   });	   
		//
//		layer.open({
//          type: 2
//          ,title: '订单详情'
//          ,shadeClose: false//点击遮罩关闭
//          ,content:baseurl+'shoporderxq'
//          ,area: ['90%', '80%']       
//          ,success : function(layero, index){
//		        var iframeWin = window[layero.find('iframe')[0]['name']];
//		        iframeWin.getdates(id);
//	        },	      
//      });      
	},
	screens:function(){
		return screen();
	},	
  },
  updated:function(){
  	this.isShow = true;
	layui.use('form', function(){
	  var form = layui.form;
	  form.render();	 
	});
  },
}
</script>
<style scoped>
/**/
</style>
